<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>jquery实现轮播图</title>
    <script src="node_modules/jquery/dist/jquery.js"></script>
    <style lang="">
        * {
            padding: 0;
            margin: 0;
            list-style: none;
            box-sizing: border-box;
        }
        
        .box {
            width: 1526px;
            height: 713px;
            position: relative;
            overflow: hidden;
            border: 20px solid #000;
        }
        
        ul {
            width: 10682px;
            position: absolute;
            overflow: hidden;
        }
        
        li {
            float: left;
        }
        
        img {
            width: 1526px;
            height: 713px;
            display: block;
        }
    </style>
</head>

<body>

    <div class="content">
        <div class="box">
            <ul>
                <li><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519569248721&di=ede6b379a8313f93856348f08b80f884&imgtype=0&src=http%3A%2F%2Fpicture.ik123.com%2Fuploads%2Fallimg%2F160712%2F3-160G2095026.jpg" alt=""></li>
                <li><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519569116327&di=20866113eba9bb65b5a09cd91b2f0331&imgtype=0&src=http%3A%2F%2Fimgstore.cdn.sogou.com%2Fapp%2Fa%2F100540002%2F494244.jpg" alt=""></li>
                <li><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519569116313&di=add98ee3c2e483b330c53da47a7f1cf4&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Fd%2F5742acdfc2d13.jpg" alt=""></li>
                <li><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519569116323&di=7ad861412e6a63e9319f8b27c6e9ef31&imgtype=0&src=http%3A%2F%2Ff2.dn.anqu.com%2Fdown%2FNjU2Nw%3D%3D%2Fallimg%2F1208%2F48-120P5160022.jpg" alt=""></li>
                <li><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519569248719&di=bd5fdfa0c99a48d5813f35c1ab2383f1&imgtype=0&src=http%3A%2F%2Fimgstore.cdn.sogou.com%2Fapp%2Fa%2F100540002%2F777194.jpg" alt=""></li>
                <li><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519569248716&di=8a0439e36d0c6425abba520097b6303f&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Fa%2F5785edffca73f.jpg%3Fdown" alt=""></li>
                <li><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519569248721&di=ede6b379a8313f93856348f08b80f884&imgtype=0&src=http%3A%2F%2Fpicture.ik123.com%2Fuploads%2Fallimg%2F160712%2F3-160G2095026.jpg" alt=""></li>
            </ul>
        </div>
    </div>

</body>

</html>
<script>
    var count = 0;
    var imgWidth = $("li").width();

    setInterval(function() {
            if (count >= $("li").length - 1) { //最后一张图片（6）
                count = 0;
                $("ul").css("left", 0);
            }
            count++;
            var target = imgWidth * count * -1;

            $("ul").animate({
                "left": target
            }, 2000);

        }, 3000) //每两秒执行一次
</script>